package com.boda.web.action.template;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.boda.web.action.BaseAction;
import com.boda.web.model.template.TestModel;
import com.boda.web.service.template.TestService;

@Controller
@Scope("prototype")
public class TestAction extends BaseAction {
    private static final long serialVersionUID = 1L;
    @Autowired
    private TestService testService;

    private TestModel model = new TestModel();

    public String list() {
        pageModel = testService.getListByPage(model, offset, pageSize);
        return SUCCESS;
    }

    public String load() {
        model = testService.getTest(id);
        return SUCCESS;
    }

    public String save() {
        if (model.getId() == null) {
            testService.add(model);
        } else {
            testService.edit(model);
        }
        return SUCCESS;
    }

    public String delete() {
        testService.delete(id);
        return SUCCESS;
    }

    public TestModel getModel() {
        return model;
    }

    public void setModel(TestModel model) {
        this.model = model;
    }

}
